/**
 * @param {Number} times 回调函数需要执行的次数
 * @param {Function} callback 回调函数
 */
export const doCustomTimes = (times: number, callback: (i: number) => any) => {
  let i = -1
  while (++i < times) {
    callback(i)
  }
}

// 防抖
export function debounce(fun: Function, wait: number) {
  let timer: any
  return function (...args: any) {
    if (timer) clearTimeout(timer)
    timer = setTimeout(() => {
      fun(args)
      clearTimeout(timer)
    }, wait)
  }
}
